package com.jike.noobmoney.helper;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.jike.noobmoney.R;
import com.zhouwei.mzbanner.holder.MZViewHolder;

/**
 * Created by kekex on 2019/1/17.
 * 加载banner的holder
 */

public class BannerViewHolder implements MZViewHolder<String> {

    private ImageView mImageView;

    @Override
    public View createView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_banner, null);
        mImageView = (ImageView) view.findViewById(R.id.banner_image);
        return view;
    }

    @Override
    public void onBind(Context context, int i, String url) {
        RequestOptions requestOptions = new RequestOptions()
                .placeholder(R.drawable.ic_default_banner)
                .error(R.drawable.ic_default_banner)
                .fitCenter();
        //.diskCacheStrategy(DiskCacheStrategy.NONE);
        Glide.with(context).load(url).apply(requestOptions).into(mImageView);
        //Glide.with(context).load(url).into(mImageView);
        //mImageView.setImageResource(R.drawable.img_banner);
    }
}
